package com.quanxiaoha.weblog.admin.controller;


import com.quanxiaoha.weblog.admin.model.vo.category.AddCategoryReqVO;
import com.quanxiaoha.weblog.admin.model.vo.category.DeleteCategoryReqVO;
import com.quanxiaoha.weblog.admin.model.vo.category.GetCategoryPageListReqVO;
import com.quanxiaoha.weblog.admin.service.AdminCategoryService;
import com.quanxiaoha.weblog.common.aspect.ApiOperationLog;
import com.quanxiaoha.weblog.common.utils.PageResponse;
import com.quanxiaoha.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/admin")
@Api(tags = "Admin分类模块")
@Slf4j
public class AdminCategoryController {

    @Autowired
    private AdminCategoryService adminCategoryService;


    @PostMapping("/category/add")
    @ApiOperation(value = "新增分类接口")
    @ApiOperationLog(description = "新增分类接口")
    public Response addCategory(@RequestBody @Validated AddCategoryReqVO addCategoryReqVO) {
        return adminCategoryService.addCategory(addCategoryReqVO);
    }


    @PostMapping("/category/list")
    @ApiOperation(value = "分页查询分类接口")
    @ApiOperationLog(description = "分页查询分类接口")
    public PageResponse getCategoryList(@RequestBody @Validated GetCategoryPageListReqVO getCategoryPageListReqVO) {
        return adminCategoryService.getCategoryList(getCategoryPageListReqVO);
    }


    @PostMapping("/category/delete")
    @ApiOperation(value = "删除分类接口")
    @ApiOperationLog(description = "删除分类接口")
    public Response deleteCategory(@RequestBody @Validated DeleteCategoryReqVO deleteCategoryReqVO) {
        return adminCategoryService.deleteCategory(deleteCategoryReqVO);
    }


    @GetMapping("/category/select/list")
    @ApiOperation(value = "分类下拉列表数据获取")
    @ApiOperationLog(description = "分类下拉列表数据获取")
    public Response selectCategoryList(){
        return adminCategoryService.getCategorySelectList();
    }
}
